tg-me.com/PineCodersSquawkBox/58
Last Update:
💪 #tip
When using security()
and you want to avoid repainting, remember that it's critical to use two techniques TOGETHER:
1. Offset the series with [1]
2. Use lookahead = barmerge.lookahead_on
noRepaintAndNoFutureData = security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)We see code in scripts that uses lookahead on but doesn't offset the series, which produces 2 adverse effects:
a) Future data is used on historical bars, which let's your script cheat and misleads traders, as there is no way your code can reproduce that behavior in realtime, because there are no future bars to cheat with then.
b) The value will repaint in realtime.
//@version=4https://www.tradingview.com/x/hkfEyExW/
study("", "", true)
noRepaintAndNoFutureData = security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
repaintsAndUsesFutureData = security(syminfo.tickerid, "D", close, lookahead = barmerge.lookahead_on)
plot(noRepaintAndNoFutureData, "Good", color.green, 2)
plot(repaintsAndUsesFutureData, "Bad", color.red, 2)
BY PineCoders Squawk Box

Share with your friend now:
tg-me.com/PineCodersSquawkBox/58